package com.woniuxy.dr_mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.dr_mall.entity.DrPerm;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
public interface DrPermMapper extends BaseMapper<DrPerm> {
    /**
     * 添加权限
     * @param drPerm
     */
    @Insert("insert into dr_perm(id,name,code,link,pid,status) values(#{id},#{name},#{code},#{link},#{pid},#{status})")
    void add(DrPerm drPerm);

    /**
     * 查询所有权限
     * @return
     */
    @Select("select * from dr_perm")
    List<DrPerm> getPerms();

    /**
     * 通过管理员ID获取权限
     * @param managerId
     * @return
     */
    @Select("select p.*from dr_perm p,dr_manager_perm m where p.id=m.permId and m.managerId=#{managerId}")
    List<DrPerm> getPermsByDrManagerId(int managerId);

    /**
     *
     * @param id
     * @param status
     */
    void updateStatus(int id, String status);
}
